package com.seecen.controller;

import com.seecen.pojo.entity.Guide;
import com.seecen.service.GuideService;
import com.seecen.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * FIND YOUR PURPOSE
 *
 * @author: CYZ
 * @date: 2025/10/20/12:24
 * @description:
 */
@Slf4j
@RestController
@RequestMapping("/api")
@CrossOrigin
public class GuideController {

    @Autowired
    private GuideService guideService;

    /**
     * 查询导游信息
     * @param searchType 搜索类型: phone-手机号, license-导游证号
     * @param searchValue 搜索值
     * @return 导游信息
     */
    @PostMapping("/guide")
    public Result getGuideInfo(@RequestParam("searchType") String searchType,
                               @RequestParam("searchValue") String searchValue) {
        log.info("查询导游信息，搜索类型：{}，搜索值：{}", searchType, searchValue);

        Guide guide = guideService.getGuideBySearchType(searchType, searchValue);
        if (guide == null) {
            return Result.build(null, com.seecen.utils.ResultCode.DATA_NOT_FOUND);
        }

        return Result.ok(guide);
    }
}